package com.dns.customers.aoptest;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
 * 切面测试
 * @author :  yulei
 * @data :  2018/6/7 11:03
 * @Version :  1.0
 **/

@Aspect
@Component
public class TestAspect {


    @Before("execution(* greetTo(..)) && target(com.dns.customers.aoptest.NaiveWaiter)")
    public void beforeGreeting(JoinPoint joinPoint){  //声明连接点入参
        System.out.println("--------------JoinPoint-----------------");
        //访问连接点信息
        System.out.println("args[0]:"+joinPoint.getArgs()[0]);

        System.out.println("signature: "+joinPoint.getSignature());
        System.out.println("target:"+ joinPoint.getTarget().getClass());

        System.out.println("--------------JoinPoint-----------------");
    }


    @Before("execution(* getAop(..)) " )
    public void beforeGreetissng(){
        System.out.println("==================计入AOP======================");
    }

    /**
     * 绑定连接点入参
     */
    @Before("target(com.dns.customers.aoptest.NaiveWaiter) && args(name,num)")
    public void bindJoinPointParams(int num,String name ){

        System.out.println("-----------bindJoinPointParams---------------");
        System.out.println("name: "+name);
        System.out.println("num: "+num);

        System.out.println("-----------bindJoinPointParams---------------");

    }

}